{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 147,
   "id": "ed5fbade",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 148,
   "id": "42bf4829",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>2021年</th>\n",
       "      <th>2020年</th>\n",
       "      <th>2019年</th>\n",
       "      <th>2018年</th>\n",
       "      <th>2017年</th>\n",
       "      <th>2016年</th>\n",
       "      <th>2015年</th>\n",
       "      <th>2014年</th>\n",
       "      <th>2013年</th>\n",
       "      <th>2012年</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>指标</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>居民人均消费支出(元)</th>\n",
       "      <td>24100.0</td>\n",
       "      <td>21210.0</td>\n",
       "      <td>21559.0</td>\n",
       "      <td>19853.0</td>\n",
       "      <td>18322.0</td>\n",
       "      <td>17111.0</td>\n",
       "      <td>15712.0</td>\n",
       "      <td>14491.0</td>\n",
       "      <td>13220.0</td>\n",
       "      <td>12054.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均消费支出比上年增长(%)</th>\n",
       "      <td>12.6</td>\n",
       "      <td>-4.0</td>\n",
       "      <td>5.5</td>\n",
       "      <td>6.2</td>\n",
       "      <td>5.4</td>\n",
       "      <td>6.8</td>\n",
       "      <td>6.9</td>\n",
       "      <td>7.5</td>\n",
       "      <td>6.9</td>\n",
       "      <td>8.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均服务性消费支出(元)</th>\n",
       "      <td>10645.0</td>\n",
       "      <td>9037.0</td>\n",
       "      <td>9886.0</td>\n",
       "      <td>8781.0</td>\n",
       "      <td>7803.0</td>\n",
       "      <td>7157.0</td>\n",
       "      <td>6460.0</td>\n",
       "      <td>5842.0</td>\n",
       "      <td>5246.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均服务性消费支出比上年增长(%)</th>\n",
       "      <td>17.8</td>\n",
       "      <td>-8.6</td>\n",
       "      <td>12.6</td>\n",
       "      <td>12.5</td>\n",
       "      <td>9.0</td>\n",
       "      <td>10.8</td>\n",
       "      <td>10.6</td>\n",
       "      <td>11.4</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均食品烟酒支出(元)</th>\n",
       "      <td>7178.0</td>\n",
       "      <td>6397.0</td>\n",
       "      <td>6084.0</td>\n",
       "      <td>5631.0</td>\n",
       "      <td>5374.0</td>\n",
       "      <td>5151.0</td>\n",
       "      <td>4814.0</td>\n",
       "      <td>4494.0</td>\n",
       "      <td>4127.0</td>\n",
       "      <td>3983.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均食品烟酒支出比上年增长(%)</th>\n",
       "      <td>NaN</td>\n",
       "      <td>5.1</td>\n",
       "      <td>8.0</td>\n",
       "      <td>4.8</td>\n",
       "      <td>4.3</td>\n",
       "      <td>7.0</td>\n",
       "      <td>7.1</td>\n",
       "      <td>8.9</td>\n",
       "      <td>3.6</td>\n",
       "      <td>9.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均衣着支出(元)</th>\n",
       "      <td>1419.0</td>\n",
       "      <td>1238.0</td>\n",
       "      <td>1338.0</td>\n",
       "      <td>1289.0</td>\n",
       "      <td>1238.0</td>\n",
       "      <td>1203.0</td>\n",
       "      <td>1164.0</td>\n",
       "      <td>1099.0</td>\n",
       "      <td>1027.0</td>\n",
       "      <td>992.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均衣着支出比上年增长(%)</th>\n",
       "      <td>NaN</td>\n",
       "      <td>-7.5</td>\n",
       "      <td>3.8</td>\n",
       "      <td>4.1</td>\n",
       "      <td>2.9</td>\n",
       "      <td>3.3</td>\n",
       "      <td>5.9</td>\n",
       "      <td>7.0</td>\n",
       "      <td>3.6</td>\n",
       "      <td>9.9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均居住支出(元)</th>\n",
       "      <td>5641.0</td>\n",
       "      <td>5215.0</td>\n",
       "      <td>5055.0</td>\n",
       "      <td>4647.0</td>\n",
       "      <td>4107.0</td>\n",
       "      <td>3746.0</td>\n",
       "      <td>3419.0</td>\n",
       "      <td>3201.0</td>\n",
       "      <td>2999.0</td>\n",
       "      <td>2480.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均居住支出比上年增长(%)</th>\n",
       "      <td>NaN</td>\n",
       "      <td>3.2</td>\n",
       "      <td>8.8</td>\n",
       "      <td>13.1</td>\n",
       "      <td>9.6</td>\n",
       "      <td>9.6</td>\n",
       "      <td>6.8</td>\n",
       "      <td>6.7</td>\n",
       "      <td>20.9</td>\n",
       "      <td>12.8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均生活用品及服务支出(元)</th>\n",
       "      <td>1423.0</td>\n",
       "      <td>1260.0</td>\n",
       "      <td>1281.0</td>\n",
       "      <td>1223.0</td>\n",
       "      <td>1121.0</td>\n",
       "      <td>1044.0</td>\n",
       "      <td>951.0</td>\n",
       "      <td>890.0</td>\n",
       "      <td>806.0</td>\n",
       "      <td>741.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均生活用品及服务支出比上年增长(%)</th>\n",
       "      <td>NaN</td>\n",
       "      <td>-1.7</td>\n",
       "      <td>4.8</td>\n",
       "      <td>9.1</td>\n",
       "      <td>7.4</td>\n",
       "      <td>9.7</td>\n",
       "      <td>6.9</td>\n",
       "      <td>10.3</td>\n",
       "      <td>8.8</td>\n",
       "      <td>9.8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均交通通信支出(元)</th>\n",
       "      <td>3156.0</td>\n",
       "      <td>2762.0</td>\n",
       "      <td>2862.0</td>\n",
       "      <td>2675.0</td>\n",
       "      <td>2499.0</td>\n",
       "      <td>2338.0</td>\n",
       "      <td>2087.0</td>\n",
       "      <td>1869.0</td>\n",
       "      <td>1627.0</td>\n",
       "      <td>1451.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均交通通信支出比上年增长(%)</th>\n",
       "      <td>NaN</td>\n",
       "      <td>-3.5</td>\n",
       "      <td>7.0</td>\n",
       "      <td>7.1</td>\n",
       "      <td>6.9</td>\n",
       "      <td>12.0</td>\n",
       "      <td>11.6</td>\n",
       "      <td>14.9</td>\n",
       "      <td>12.2</td>\n",
       "      <td>15.3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均教育文化娱乐支出(元)</th>\n",
       "      <td>2599.0</td>\n",
       "      <td>2032.0</td>\n",
       "      <td>2513.0</td>\n",
       "      <td>2226.0</td>\n",
       "      <td>2086.0</td>\n",
       "      <td>1915.0</td>\n",
       "      <td>1723.0</td>\n",
       "      <td>1536.0</td>\n",
       "      <td>1398.0</td>\n",
       "      <td>1262.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均教育文化娱乐支出比上年增长(%)</th>\n",
       "      <td>NaN</td>\n",
       "      <td>-19.1</td>\n",
       "      <td>12.9</td>\n",
       "      <td>6.7</td>\n",
       "      <td>8.9</td>\n",
       "      <td>11.2</td>\n",
       "      <td>12.2</td>\n",
       "      <td>9.9</td>\n",
       "      <td>10.8</td>\n",
       "      <td>11.1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均医疗保健支出(元)</th>\n",
       "      <td>2115.0</td>\n",
       "      <td>1843.0</td>\n",
       "      <td>1902.0</td>\n",
       "      <td>1685.0</td>\n",
       "      <td>1451.0</td>\n",
       "      <td>1307.0</td>\n",
       "      <td>1165.0</td>\n",
       "      <td>1045.0</td>\n",
       "      <td>912.0</td>\n",
       "      <td>838.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均医疗保健支出比上年增长(%)</th>\n",
       "      <td>NaN</td>\n",
       "      <td>-3.1</td>\n",
       "      <td>12.9</td>\n",
       "      <td>16.1</td>\n",
       "      <td>11.0</td>\n",
       "      <td>12.3</td>\n",
       "      <td>11.5</td>\n",
       "      <td>14.5</td>\n",
       "      <td>8.8</td>\n",
       "      <td>12.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均其他用品及服务支出(元)</th>\n",
       "      <td>569.0</td>\n",
       "      <td>462.0</td>\n",
       "      <td>524.0</td>\n",
       "      <td>477.0</td>\n",
       "      <td>447.0</td>\n",
       "      <td>406.0</td>\n",
       "      <td>389.0</td>\n",
       "      <td>358.0</td>\n",
       "      <td>325.0</td>\n",
       "      <td>307.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均其他用品及服务支出比上年增长(%)</th>\n",
       "      <td>NaN</td>\n",
       "      <td>-11.8</td>\n",
       "      <td>9.7</td>\n",
       "      <td>6.8</td>\n",
       "      <td>10.0</td>\n",
       "      <td>4.4</td>\n",
       "      <td>8.7</td>\n",
       "      <td>10.3</td>\n",
       "      <td>5.6</td>\n",
       "      <td>12.9</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                         2021年    2020年    2019年    2018年    2017年    2016年  \\\n",
       "指标                                                                            \n",
       "居民人均消费支出(元)            24100.0  21210.0  21559.0  19853.0  18322.0  17111.0   \n",
       "居民人均消费支出比上年增长(%)          12.6     -4.0      5.5      6.2      5.4      6.8   \n",
       "居民人均服务性消费支出(元)         10645.0   9037.0   9886.0   8781.0   7803.0   7157.0   \n",
       "居民人均服务性消费支出比上年增长(%)       17.8     -8.6     12.6     12.5      9.0     10.8   \n",
       "居民人均食品烟酒支出(元)           7178.0   6397.0   6084.0   5631.0   5374.0   5151.0   \n",
       "居民人均食品烟酒支出比上年增长(%)         NaN      5.1      8.0      4.8      4.3      7.0   \n",
       "居民人均衣着支出(元)             1419.0   1238.0   1338.0   1289.0   1238.0   1203.0   \n",
       "居民人均衣着支出比上年增长(%)           NaN     -7.5      3.8      4.1      2.9      3.3   \n",
       "居民人均居住支出(元)             5641.0   5215.0   5055.0   4647.0   4107.0   3746.0   \n",
       "居民人均居住支出比上年增长(%)           NaN      3.2      8.8     13.1      9.6      9.6   \n",
       "居民人均生活用品及服务支出(元)        1423.0   1260.0   1281.0   1223.0   1121.0   1044.0   \n",
       "居民人均生活用品及服务支出比上年增长(%)      NaN     -1.7      4.8      9.1      7.4      9.7   \n",
       "居民人均交通通信支出(元)           3156.0   2762.0   2862.0   2675.0   2499.0   2338.0   \n",
       "居民人均交通通信支出比上年增长(%)         NaN     -3.5      7.0      7.1      6.9     12.0   \n",
       "居民人均教育文化娱乐支出(元)         2599.0   2032.0   2513.0   2226.0   2086.0   1915.0   \n",
       "居民人均教育文化娱乐支出比上年增长(%)       NaN    -19.1     12.9      6.7      8.9     11.2   \n",
       "居民人均医疗保健支出(元)           2115.0   1843.0   1902.0   1685.0   1451.0   1307.0   \n",
       "居民人均医疗保健支出比上年增长(%)         NaN     -3.1     12.9     16.1     11.0     12.3   \n",
       "居民人均其他用品及服务支出(元)         569.0    462.0    524.0    477.0    447.0    406.0   \n",
       "居民人均其他用品及服务支出比上年增长(%)      NaN    -11.8      9.7      6.8     10.0      4.4   \n",
       "\n",
       "                         2015年    2014年    2013年    2012年  \n",
       "指标                                                         \n",
       "居民人均消费支出(元)            15712.0  14491.0  13220.0  12054.0  \n",
       "居民人均消费支出比上年增长(%)           6.9      7.5      6.9      8.6  \n",
       "居民人均服务性消费支出(元)          6460.0   5842.0   5246.0      NaN  \n",
       "居民人均服务性消费支出比上年增长(%)       10.6     11.4      NaN      NaN  \n",
       "居民人均食品烟酒支出(元)           4814.0   4494.0   4127.0   3983.0  \n",
       "居民人均食品烟酒支出比上年增长(%)         7.1      8.9      3.6      9.6  \n",
       "居民人均衣着支出(元)             1164.0   1099.0   1027.0    992.0  \n",
       "居民人均衣着支出比上年增长(%)           5.9      7.0      3.6      9.9  \n",
       "居民人均居住支出(元)             3419.0   3201.0   2999.0   2480.0  \n",
       "居民人均居住支出比上年增长(%)           6.8      6.7     20.9     12.8  \n",
       "居民人均生活用品及服务支出(元)         951.0    890.0    806.0    741.0  \n",
       "居民人均生活用品及服务支出比上年增长(%)      6.9     10.3      8.8      9.8  \n",
       "居民人均交通通信支出(元)           2087.0   1869.0   1627.0   1451.0  \n",
       "居民人均交通通信支出比上年增长(%)        11.6     14.9     12.2     15.3  \n",
       "居民人均教育文化娱乐支出(元)         1723.0   1536.0   1398.0   1262.0  \n",
       "居民人均教育文化娱乐支出比上年增长(%)      12.2      9.9     10.8     11.1  \n",
       "居民人均医疗保健支出(元)           1165.0   1045.0    912.0    838.0  \n",
       "居民人均医疗保健支出比上年增长(%)        11.5     14.5      8.8     12.7  \n",
       "居民人均其他用品及服务支出(元)         389.0    358.0    325.0    307.0  \n",
       "居民人均其他用品及服务支出比上年增长(%)      8.7     10.3      5.6     12.9  "
      ]
     },
     "execution_count": 148,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 读取文件\n",
    "df1 = pd.read_csv('年度数据.csv',index_col=0,encoding='gb2312')\n",
    "#df1 = df1.head()\n",
    "df1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 149,
   "id": "a27e0fb3",
   "metadata": {},
   "outputs": [],
   "source": [
    "#df1[['2021年','2012年']]\n",
    "#df1.iloc[:2,2:]\n",
    "#df1.loc['居民人均消费支出比上年增长(%)':'居民人均服务性消费支出(元)','2018年':'2015年']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 150,
   "id": "1b1ba396",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(20, 10)"
      ]
     },
     "execution_count": 150,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df1.shape #查看数据大小，返回一个元祖（行数,列数）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 151,
   "id": "99bda988",
   "metadata": {},
   "outputs": [],
   "source": [
    "#df2 = df1.reindex([1,2,3,4,0]) # 更改索引顺序，列表为已经存在的索引\n",
    "#print(df1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 152,
   "id": "359b37c5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>2021年</th>\n",
       "      <th>2020年</th>\n",
       "      <th>2019年</th>\n",
       "      <th>2018年</th>\n",
       "      <th>2017年</th>\n",
       "      <th>2016年</th>\n",
       "      <th>2015年</th>\n",
       "      <th>2014年</th>\n",
       "      <th>2013年</th>\n",
       "      <th>2012年</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>指标</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>居民人均消费支出(元)</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均消费支出比上年增长(%)</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均服务性消费支出(元)</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均服务性消费支出比上年增长(%)</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均食品烟酒支出(元)</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均食品烟酒支出比上年增长(%)</th>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均衣着支出(元)</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均衣着支出比上年增长(%)</th>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均居住支出(元)</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均居住支出比上年增长(%)</th>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均生活用品及服务支出(元)</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均生活用品及服务支出比上年增长(%)</th>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均交通通信支出(元)</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均交通通信支出比上年增长(%)</th>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均教育文化娱乐支出(元)</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均教育文化娱乐支出比上年增长(%)</th>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均医疗保健支出(元)</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均医疗保健支出比上年增长(%)</th>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均其他用品及服务支出(元)</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均其他用品及服务支出比上年增长(%)</th>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                       2021年  2020年  2019年  2018年  2017年  2016年  2015年  2014年  \\\n",
       "指标                                                                              \n",
       "居民人均消费支出(元)            False  False  False  False  False  False  False  False   \n",
       "居民人均消费支出比上年增长(%)       False  False  False  False  False  False  False  False   \n",
       "居民人均服务性消费支出(元)         False  False  False  False  False  False  False  False   \n",
       "居民人均服务性消费支出比上年增长(%)    False  False  False  False  False  False  False  False   \n",
       "居民人均食品烟酒支出(元)          False  False  False  False  False  False  False  False   \n",
       "居民人均食品烟酒支出比上年增长(%)      True  False  False  False  False  False  False  False   \n",
       "居民人均衣着支出(元)            False  False  False  False  False  False  False  False   \n",
       "居民人均衣着支出比上年增长(%)        True  False  False  False  False  False  False  False   \n",
       "居民人均居住支出(元)            False  False  False  False  False  False  False  False   \n",
       "居民人均居住支出比上年增长(%)        True  False  False  False  False  False  False  False   \n",
       "居民人均生活用品及服务支出(元)       False  False  False  False  False  False  False  False   \n",
       "居民人均生活用品及服务支出比上年增长(%)   True  False  False  False  False  False  False  False   \n",
       "居民人均交通通信支出(元)          False  False  False  False  False  False  False  False   \n",
       "居民人均交通通信支出比上年增长(%)      True  False  False  False  False  False  False  False   \n",
       "居民人均教育文化娱乐支出(元)        False  False  False  False  False  False  False  False   \n",
       "居民人均教育文化娱乐支出比上年增长(%)    True  False  False  False  False  False  False  False   \n",
       "居民人均医疗保健支出(元)          False  False  False  False  False  False  False  False   \n",
       "居民人均医疗保健支出比上年增长(%)      True  False  False  False  False  False  False  False   \n",
       "居民人均其他用品及服务支出(元)       False  False  False  False  False  False  False  False   \n",
       "居民人均其他用品及服务支出比上年增长(%)   True  False  False  False  False  False  False  False   \n",
       "\n",
       "                       2013年  2012年  \n",
       "指标                                   \n",
       "居民人均消费支出(元)            False  False  \n",
       "居民人均消费支出比上年增长(%)       False  False  \n",
       "居民人均服务性消费支出(元)         False   True  \n",
       "居民人均服务性消费支出比上年增长(%)     True   True  \n",
       "居民人均食品烟酒支出(元)          False  False  \n",
       "居民人均食品烟酒支出比上年增长(%)     False  False  \n",
       "居民人均衣着支出(元)            False  False  \n",
       "居民人均衣着支出比上年增长(%)       False  False  \n",
       "居民人均居住支出(元)            False  False  \n",
       "居民人均居住支出比上年增长(%)       False  False  \n",
       "居民人均生活用品及服务支出(元)       False  False  \n",
       "居民人均生活用品及服务支出比上年增长(%)  False  False  \n",
       "居民人均交通通信支出(元)          False  False  \n",
       "居民人均交通通信支出比上年增长(%)     False  False  \n",
       "居民人均教育文化娱乐支出(元)        False  False  \n",
       "居民人均教育文化娱乐支出比上年增长(%)   False  False  \n",
       "居民人均医疗保健支出(元)          False  False  \n",
       "居民人均医疗保健支出比上年增长(%)     False  False  \n",
       "居民人均其他用品及服务支出(元)       False  False  \n",
       "居民人均其他用品及服务支出比上年增长(%)  False  False  "
      ]
     },
     "execution_count": 152,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df1 #Not a Number 不是一个数字，空数字\n",
    "df1.isnull()\n",
    "#df1.dropna(axis=0,how='any',thresh=None) # 删除NaN值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 153,
   "id": "fc6c345c",
   "metadata": {},
   "outputs": [],
   "source": [
    "df1 = df1.fillna(method='ffill',axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 154,
   "id": "05dc2228",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>2021年</th>\n",
       "      <th>2020年</th>\n",
       "      <th>2019年</th>\n",
       "      <th>2018年</th>\n",
       "      <th>2017年</th>\n",
       "      <th>2016年</th>\n",
       "      <th>2015年</th>\n",
       "      <th>2014年</th>\n",
       "      <th>2013年</th>\n",
       "      <th>2012年</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>指标</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>居民人均消费支出(元)</th>\n",
       "      <td>24100.0</td>\n",
       "      <td>21210.0</td>\n",
       "      <td>21559.0</td>\n",
       "      <td>19853.0</td>\n",
       "      <td>18322.0</td>\n",
       "      <td>17111.0</td>\n",
       "      <td>15712.0</td>\n",
       "      <td>14491.0</td>\n",
       "      <td>13220.0</td>\n",
       "      <td>12054.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均消费支出比上年增长(%)</th>\n",
       "      <td>12.6</td>\n",
       "      <td>-4.0</td>\n",
       "      <td>5.5</td>\n",
       "      <td>6.2</td>\n",
       "      <td>5.4</td>\n",
       "      <td>6.8</td>\n",
       "      <td>6.9</td>\n",
       "      <td>7.5</td>\n",
       "      <td>6.9</td>\n",
       "      <td>8.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均服务性消费支出(元)</th>\n",
       "      <td>10645.0</td>\n",
       "      <td>9037.0</td>\n",
       "      <td>9886.0</td>\n",
       "      <td>8781.0</td>\n",
       "      <td>7803.0</td>\n",
       "      <td>7157.0</td>\n",
       "      <td>6460.0</td>\n",
       "      <td>5842.0</td>\n",
       "      <td>5246.0</td>\n",
       "      <td>5246.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均服务性消费支出比上年增长(%)</th>\n",
       "      <td>17.8</td>\n",
       "      <td>-8.6</td>\n",
       "      <td>12.6</td>\n",
       "      <td>12.5</td>\n",
       "      <td>9.0</td>\n",
       "      <td>10.8</td>\n",
       "      <td>10.6</td>\n",
       "      <td>11.4</td>\n",
       "      <td>11.4</td>\n",
       "      <td>11.4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均食品烟酒支出(元)</th>\n",
       "      <td>7178.0</td>\n",
       "      <td>6397.0</td>\n",
       "      <td>6084.0</td>\n",
       "      <td>5631.0</td>\n",
       "      <td>5374.0</td>\n",
       "      <td>5151.0</td>\n",
       "      <td>4814.0</td>\n",
       "      <td>4494.0</td>\n",
       "      <td>4127.0</td>\n",
       "      <td>3983.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均食品烟酒支出比上年增长(%)</th>\n",
       "      <td>5.1</td>\n",
       "      <td>5.1</td>\n",
       "      <td>8.0</td>\n",
       "      <td>4.8</td>\n",
       "      <td>4.3</td>\n",
       "      <td>7.0</td>\n",
       "      <td>7.1</td>\n",
       "      <td>8.9</td>\n",
       "      <td>3.6</td>\n",
       "      <td>9.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均衣着支出(元)</th>\n",
       "      <td>1419.0</td>\n",
       "      <td>1238.0</td>\n",
       "      <td>1338.0</td>\n",
       "      <td>1289.0</td>\n",
       "      <td>1238.0</td>\n",
       "      <td>1203.0</td>\n",
       "      <td>1164.0</td>\n",
       "      <td>1099.0</td>\n",
       "      <td>1027.0</td>\n",
       "      <td>992.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均衣着支出比上年增长(%)</th>\n",
       "      <td>-7.5</td>\n",
       "      <td>-7.5</td>\n",
       "      <td>3.8</td>\n",
       "      <td>4.1</td>\n",
       "      <td>2.9</td>\n",
       "      <td>3.3</td>\n",
       "      <td>5.9</td>\n",
       "      <td>7.0</td>\n",
       "      <td>3.6</td>\n",
       "      <td>9.9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均居住支出(元)</th>\n",
       "      <td>5641.0</td>\n",
       "      <td>5215.0</td>\n",
       "      <td>5055.0</td>\n",
       "      <td>4647.0</td>\n",
       "      <td>4107.0</td>\n",
       "      <td>3746.0</td>\n",
       "      <td>3419.0</td>\n",
       "      <td>3201.0</td>\n",
       "      <td>2999.0</td>\n",
       "      <td>2480.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均居住支出比上年增长(%)</th>\n",
       "      <td>3.2</td>\n",
       "      <td>3.2</td>\n",
       "      <td>8.8</td>\n",
       "      <td>13.1</td>\n",
       "      <td>9.6</td>\n",
       "      <td>9.6</td>\n",
       "      <td>6.8</td>\n",
       "      <td>6.7</td>\n",
       "      <td>20.9</td>\n",
       "      <td>12.8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均生活用品及服务支出(元)</th>\n",
       "      <td>1423.0</td>\n",
       "      <td>1260.0</td>\n",
       "      <td>1281.0</td>\n",
       "      <td>1223.0</td>\n",
       "      <td>1121.0</td>\n",
       "      <td>1044.0</td>\n",
       "      <td>951.0</td>\n",
       "      <td>890.0</td>\n",
       "      <td>806.0</td>\n",
       "      <td>741.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均生活用品及服务支出比上年增长(%)</th>\n",
       "      <td>-1.7</td>\n",
       "      <td>-1.7</td>\n",
       "      <td>4.8</td>\n",
       "      <td>9.1</td>\n",
       "      <td>7.4</td>\n",
       "      <td>9.7</td>\n",
       "      <td>6.9</td>\n",
       "      <td>10.3</td>\n",
       "      <td>8.8</td>\n",
       "      <td>9.8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均交通通信支出(元)</th>\n",
       "      <td>3156.0</td>\n",
       "      <td>2762.0</td>\n",
       "      <td>2862.0</td>\n",
       "      <td>2675.0</td>\n",
       "      <td>2499.0</td>\n",
       "      <td>2338.0</td>\n",
       "      <td>2087.0</td>\n",
       "      <td>1869.0</td>\n",
       "      <td>1627.0</td>\n",
       "      <td>1451.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均交通通信支出比上年增长(%)</th>\n",
       "      <td>-3.5</td>\n",
       "      <td>-3.5</td>\n",
       "      <td>7.0</td>\n",
       "      <td>7.1</td>\n",
       "      <td>6.9</td>\n",
       "      <td>12.0</td>\n",
       "      <td>11.6</td>\n",
       "      <td>14.9</td>\n",
       "      <td>12.2</td>\n",
       "      <td>15.3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均教育文化娱乐支出(元)</th>\n",
       "      <td>2599.0</td>\n",
       "      <td>2032.0</td>\n",
       "      <td>2513.0</td>\n",
       "      <td>2226.0</td>\n",
       "      <td>2086.0</td>\n",
       "      <td>1915.0</td>\n",
       "      <td>1723.0</td>\n",
       "      <td>1536.0</td>\n",
       "      <td>1398.0</td>\n",
       "      <td>1262.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均教育文化娱乐支出比上年增长(%)</th>\n",
       "      <td>-19.1</td>\n",
       "      <td>-19.1</td>\n",
       "      <td>12.9</td>\n",
       "      <td>6.7</td>\n",
       "      <td>8.9</td>\n",
       "      <td>11.2</td>\n",
       "      <td>12.2</td>\n",
       "      <td>9.9</td>\n",
       "      <td>10.8</td>\n",
       "      <td>11.1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均医疗保健支出(元)</th>\n",
       "      <td>2115.0</td>\n",
       "      <td>1843.0</td>\n",
       "      <td>1902.0</td>\n",
       "      <td>1685.0</td>\n",
       "      <td>1451.0</td>\n",
       "      <td>1307.0</td>\n",
       "      <td>1165.0</td>\n",
       "      <td>1045.0</td>\n",
       "      <td>912.0</td>\n",
       "      <td>838.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均医疗保健支出比上年增长(%)</th>\n",
       "      <td>-3.1</td>\n",
       "      <td>-3.1</td>\n",
       "      <td>12.9</td>\n",
       "      <td>16.1</td>\n",
       "      <td>11.0</td>\n",
       "      <td>12.3</td>\n",
       "      <td>11.5</td>\n",
       "      <td>14.5</td>\n",
       "      <td>8.8</td>\n",
       "      <td>12.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均其他用品及服务支出(元)</th>\n",
       "      <td>569.0</td>\n",
       "      <td>462.0</td>\n",
       "      <td>524.0</td>\n",
       "      <td>477.0</td>\n",
       "      <td>447.0</td>\n",
       "      <td>406.0</td>\n",
       "      <td>389.0</td>\n",
       "      <td>358.0</td>\n",
       "      <td>325.0</td>\n",
       "      <td>307.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均其他用品及服务支出比上年增长(%)</th>\n",
       "      <td>-11.8</td>\n",
       "      <td>-11.8</td>\n",
       "      <td>9.7</td>\n",
       "      <td>6.8</td>\n",
       "      <td>10.0</td>\n",
       "      <td>4.4</td>\n",
       "      <td>8.7</td>\n",
       "      <td>10.3</td>\n",
       "      <td>5.6</td>\n",
       "      <td>12.9</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                         2021年    2020年    2019年    2018年    2017年    2016年  \\\n",
       "指标                                                                            \n",
       "居民人均消费支出(元)            24100.0  21210.0  21559.0  19853.0  18322.0  17111.0   \n",
       "居民人均消费支出比上年增长(%)          12.6     -4.0      5.5      6.2      5.4      6.8   \n",
       "居民人均服务性消费支出(元)         10645.0   9037.0   9886.0   8781.0   7803.0   7157.0   \n",
       "居民人均服务性消费支出比上年增长(%)       17.8     -8.6     12.6     12.5      9.0     10.8   \n",
       "居民人均食品烟酒支出(元)           7178.0   6397.0   6084.0   5631.0   5374.0   5151.0   \n",
       "居民人均食品烟酒支出比上年增长(%)         5.1      5.1      8.0      4.8      4.3      7.0   \n",
       "居民人均衣着支出(元)             1419.0   1238.0   1338.0   1289.0   1238.0   1203.0   \n",
       "居民人均衣着支出比上年增长(%)          -7.5     -7.5      3.8      4.1      2.9      3.3   \n",
       "居民人均居住支出(元)             5641.0   5215.0   5055.0   4647.0   4107.0   3746.0   \n",
       "居民人均居住支出比上年增长(%)           3.2      3.2      8.8     13.1      9.6      9.6   \n",
       "居民人均生活用品及服务支出(元)        1423.0   1260.0   1281.0   1223.0   1121.0   1044.0   \n",
       "居民人均生活用品及服务支出比上年增长(%)     -1.7     -1.7      4.8      9.1      7.4      9.7   \n",
       "居民人均交通通信支出(元)           3156.0   2762.0   2862.0   2675.0   2499.0   2338.0   \n",
       "居民人均交通通信支出比上年增长(%)        -3.5     -3.5      7.0      7.1      6.9     12.0   \n",
       "居民人均教育文化娱乐支出(元)         2599.0   2032.0   2513.0   2226.0   2086.0   1915.0   \n",
       "居民人均教育文化娱乐支出比上年增长(%)     -19.1    -19.1     12.9      6.7      8.9     11.2   \n",
       "居民人均医疗保健支出(元)           2115.0   1843.0   1902.0   1685.0   1451.0   1307.0   \n",
       "居民人均医疗保健支出比上年增长(%)        -3.1     -3.1     12.9     16.1     11.0     12.3   \n",
       "居民人均其他用品及服务支出(元)         569.0    462.0    524.0    477.0    447.0    406.0   \n",
       "居民人均其他用品及服务支出比上年增长(%)    -11.8    -11.8      9.7      6.8     10.0      4.4   \n",
       "\n",
       "                         2015年    2014年    2013年    2012年  \n",
       "指标                                                         \n",
       "居民人均消费支出(元)            15712.0  14491.0  13220.0  12054.0  \n",
       "居民人均消费支出比上年增长(%)           6.9      7.5      6.9      8.6  \n",
       "居民人均服务性消费支出(元)          6460.0   5842.0   5246.0   5246.0  \n",
       "居民人均服务性消费支出比上年增长(%)       10.6     11.4     11.4     11.4  \n",
       "居民人均食品烟酒支出(元)           4814.0   4494.0   4127.0   3983.0  \n",
       "居民人均食品烟酒支出比上年增长(%)         7.1      8.9      3.6      9.6  \n",
       "居民人均衣着支出(元)             1164.0   1099.0   1027.0    992.0  \n",
       "居民人均衣着支出比上年增长(%)           5.9      7.0      3.6      9.9  \n",
       "居民人均居住支出(元)             3419.0   3201.0   2999.0   2480.0  \n",
       "居民人均居住支出比上年增长(%)           6.8      6.7     20.9     12.8  \n",
       "居民人均生活用品及服务支出(元)         951.0    890.0    806.0    741.0  \n",
       "居民人均生活用品及服务支出比上年增长(%)      6.9     10.3      8.8      9.8  \n",
       "居民人均交通通信支出(元)           2087.0   1869.0   1627.0   1451.0  \n",
       "居民人均交通通信支出比上年增长(%)        11.6     14.9     12.2     15.3  \n",
       "居民人均教育文化娱乐支出(元)         1723.0   1536.0   1398.0   1262.0  \n",
       "居民人均教育文化娱乐支出比上年增长(%)      12.2      9.9     10.8     11.1  \n",
       "居民人均医疗保健支出(元)           1165.0   1045.0    912.0    838.0  \n",
       "居民人均医疗保健支出比上年增长(%)        11.5     14.5      8.8     12.7  \n",
       "居民人均其他用品及服务支出(元)         389.0    358.0    325.0    307.0  \n",
       "居民人均其他用品及服务支出比上年增长(%)      8.7     10.3      5.6     12.9  "
      ]
     },
     "execution_count": 154,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df1 = df1.fillna(method='bfill',axis=1)\n",
    "df1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 155,
   "id": "0665e5f1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>指标</th>\n",
       "      <th>居民人均消费支出(元)</th>\n",
       "      <th>居民人均消费支出比上年增长(%)</th>\n",
       "      <th>居民人均服务性消费支出(元)</th>\n",
       "      <th>居民人均服务性消费支出比上年增长(%)</th>\n",
       "      <th>居民人均食品烟酒支出(元)</th>\n",
       "      <th>居民人均食品烟酒支出比上年增长(%)</th>\n",
       "      <th>居民人均衣着支出(元)</th>\n",
       "      <th>居民人均衣着支出比上年增长(%)</th>\n",
       "      <th>居民人均居住支出(元)</th>\n",
       "      <th>居民人均居住支出比上年增长(%)</th>\n",
       "      <th>居民人均生活用品及服务支出(元)</th>\n",
       "      <th>居民人均生活用品及服务支出比上年增长(%)</th>\n",
       "      <th>居民人均交通通信支出(元)</th>\n",
       "      <th>居民人均交通通信支出比上年增长(%)</th>\n",
       "      <th>居民人均教育文化娱乐支出(元)</th>\n",
       "      <th>居民人均教育文化娱乐支出比上年增长(%)</th>\n",
       "      <th>居民人均医疗保健支出(元)</th>\n",
       "      <th>居民人均医疗保健支出比上年增长(%)</th>\n",
       "      <th>居民人均其他用品及服务支出(元)</th>\n",
       "      <th>居民人均其他用品及服务支出比上年增长(%)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2021年</th>\n",
       "      <td>24100.0</td>\n",
       "      <td>12.6</td>\n",
       "      <td>10645.0</td>\n",
       "      <td>17.8</td>\n",
       "      <td>7178.0</td>\n",
       "      <td>5.1</td>\n",
       "      <td>1419.0</td>\n",
       "      <td>-7.5</td>\n",
       "      <td>5641.0</td>\n",
       "      <td>3.2</td>\n",
       "      <td>1423.0</td>\n",
       "      <td>-1.7</td>\n",
       "      <td>3156.0</td>\n",
       "      <td>-3.5</td>\n",
       "      <td>2599.0</td>\n",
       "      <td>-19.1</td>\n",
       "      <td>2115.0</td>\n",
       "      <td>-3.1</td>\n",
       "      <td>569.0</td>\n",
       "      <td>-11.8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020年</th>\n",
       "      <td>21210.0</td>\n",
       "      <td>-4.0</td>\n",
       "      <td>9037.0</td>\n",
       "      <td>-8.6</td>\n",
       "      <td>6397.0</td>\n",
       "      <td>5.1</td>\n",
       "      <td>1238.0</td>\n",
       "      <td>-7.5</td>\n",
       "      <td>5215.0</td>\n",
       "      <td>3.2</td>\n",
       "      <td>1260.0</td>\n",
       "      <td>-1.7</td>\n",
       "      <td>2762.0</td>\n",
       "      <td>-3.5</td>\n",
       "      <td>2032.0</td>\n",
       "      <td>-19.1</td>\n",
       "      <td>1843.0</td>\n",
       "      <td>-3.1</td>\n",
       "      <td>462.0</td>\n",
       "      <td>-11.8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019年</th>\n",
       "      <td>21559.0</td>\n",
       "      <td>5.5</td>\n",
       "      <td>9886.0</td>\n",
       "      <td>12.6</td>\n",
       "      <td>6084.0</td>\n",
       "      <td>8.0</td>\n",
       "      <td>1338.0</td>\n",
       "      <td>3.8</td>\n",
       "      <td>5055.0</td>\n",
       "      <td>8.8</td>\n",
       "      <td>1281.0</td>\n",
       "      <td>4.8</td>\n",
       "      <td>2862.0</td>\n",
       "      <td>7.0</td>\n",
       "      <td>2513.0</td>\n",
       "      <td>12.9</td>\n",
       "      <td>1902.0</td>\n",
       "      <td>12.9</td>\n",
       "      <td>524.0</td>\n",
       "      <td>9.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018年</th>\n",
       "      <td>19853.0</td>\n",
       "      <td>6.2</td>\n",
       "      <td>8781.0</td>\n",
       "      <td>12.5</td>\n",
       "      <td>5631.0</td>\n",
       "      <td>4.8</td>\n",
       "      <td>1289.0</td>\n",
       "      <td>4.1</td>\n",
       "      <td>4647.0</td>\n",
       "      <td>13.1</td>\n",
       "      <td>1223.0</td>\n",
       "      <td>9.1</td>\n",
       "      <td>2675.0</td>\n",
       "      <td>7.1</td>\n",
       "      <td>2226.0</td>\n",
       "      <td>6.7</td>\n",
       "      <td>1685.0</td>\n",
       "      <td>16.1</td>\n",
       "      <td>477.0</td>\n",
       "      <td>6.8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017年</th>\n",
       "      <td>18322.0</td>\n",
       "      <td>5.4</td>\n",
       "      <td>7803.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>5374.0</td>\n",
       "      <td>4.3</td>\n",
       "      <td>1238.0</td>\n",
       "      <td>2.9</td>\n",
       "      <td>4107.0</td>\n",
       "      <td>9.6</td>\n",
       "      <td>1121.0</td>\n",
       "      <td>7.4</td>\n",
       "      <td>2499.0</td>\n",
       "      <td>6.9</td>\n",
       "      <td>2086.0</td>\n",
       "      <td>8.9</td>\n",
       "      <td>1451.0</td>\n",
       "      <td>11.0</td>\n",
       "      <td>447.0</td>\n",
       "      <td>10.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016年</th>\n",
       "      <td>17111.0</td>\n",
       "      <td>6.8</td>\n",
       "      <td>7157.0</td>\n",
       "      <td>10.8</td>\n",
       "      <td>5151.0</td>\n",
       "      <td>7.0</td>\n",
       "      <td>1203.0</td>\n",
       "      <td>3.3</td>\n",
       "      <td>3746.0</td>\n",
       "      <td>9.6</td>\n",
       "      <td>1044.0</td>\n",
       "      <td>9.7</td>\n",
       "      <td>2338.0</td>\n",
       "      <td>12.0</td>\n",
       "      <td>1915.0</td>\n",
       "      <td>11.2</td>\n",
       "      <td>1307.0</td>\n",
       "      <td>12.3</td>\n",
       "      <td>406.0</td>\n",
       "      <td>4.4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015年</th>\n",
       "      <td>15712.0</td>\n",
       "      <td>6.9</td>\n",
       "      <td>6460.0</td>\n",
       "      <td>10.6</td>\n",
       "      <td>4814.0</td>\n",
       "      <td>7.1</td>\n",
       "      <td>1164.0</td>\n",
       "      <td>5.9</td>\n",
       "      <td>3419.0</td>\n",
       "      <td>6.8</td>\n",
       "      <td>951.0</td>\n",
       "      <td>6.9</td>\n",
       "      <td>2087.0</td>\n",
       "      <td>11.6</td>\n",
       "      <td>1723.0</td>\n",
       "      <td>12.2</td>\n",
       "      <td>1165.0</td>\n",
       "      <td>11.5</td>\n",
       "      <td>389.0</td>\n",
       "      <td>8.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2014年</th>\n",
       "      <td>14491.0</td>\n",
       "      <td>7.5</td>\n",
       "      <td>5842.0</td>\n",
       "      <td>11.4</td>\n",
       "      <td>4494.0</td>\n",
       "      <td>8.9</td>\n",
       "      <td>1099.0</td>\n",
       "      <td>7.0</td>\n",
       "      <td>3201.0</td>\n",
       "      <td>6.7</td>\n",
       "      <td>890.0</td>\n",
       "      <td>10.3</td>\n",
       "      <td>1869.0</td>\n",
       "      <td>14.9</td>\n",
       "      <td>1536.0</td>\n",
       "      <td>9.9</td>\n",
       "      <td>1045.0</td>\n",
       "      <td>14.5</td>\n",
       "      <td>358.0</td>\n",
       "      <td>10.3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013年</th>\n",
       "      <td>13220.0</td>\n",
       "      <td>6.9</td>\n",
       "      <td>5246.0</td>\n",
       "      <td>11.4</td>\n",
       "      <td>4127.0</td>\n",
       "      <td>3.6</td>\n",
       "      <td>1027.0</td>\n",
       "      <td>3.6</td>\n",
       "      <td>2999.0</td>\n",
       "      <td>20.9</td>\n",
       "      <td>806.0</td>\n",
       "      <td>8.8</td>\n",
       "      <td>1627.0</td>\n",
       "      <td>12.2</td>\n",
       "      <td>1398.0</td>\n",
       "      <td>10.8</td>\n",
       "      <td>912.0</td>\n",
       "      <td>8.8</td>\n",
       "      <td>325.0</td>\n",
       "      <td>5.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2012年</th>\n",
       "      <td>12054.0</td>\n",
       "      <td>8.6</td>\n",
       "      <td>5246.0</td>\n",
       "      <td>11.4</td>\n",
       "      <td>3983.0</td>\n",
       "      <td>9.6</td>\n",
       "      <td>992.0</td>\n",
       "      <td>9.9</td>\n",
       "      <td>2480.0</td>\n",
       "      <td>12.8</td>\n",
       "      <td>741.0</td>\n",
       "      <td>9.8</td>\n",
       "      <td>1451.0</td>\n",
       "      <td>15.3</td>\n",
       "      <td>1262.0</td>\n",
       "      <td>11.1</td>\n",
       "      <td>838.0</td>\n",
       "      <td>12.7</td>\n",
       "      <td>307.0</td>\n",
       "      <td>12.9</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "指标     居民人均消费支出(元)  居民人均消费支出比上年增长(%)  居民人均服务性消费支出(元)  居民人均服务性消费支出比上年增长(%)  \\\n",
       "2021年      24100.0              12.6         10645.0                 17.8   \n",
       "2020年      21210.0              -4.0          9037.0                 -8.6   \n",
       "2019年      21559.0               5.5          9886.0                 12.6   \n",
       "2018年      19853.0               6.2          8781.0                 12.5   \n",
       "2017年      18322.0               5.4          7803.0                  9.0   \n",
       "2016年      17111.0               6.8          7157.0                 10.8   \n",
       "2015年      15712.0               6.9          6460.0                 10.6   \n",
       "2014年      14491.0               7.5          5842.0                 11.4   \n",
       "2013年      13220.0               6.9          5246.0                 11.4   \n",
       "2012年      12054.0               8.6          5246.0                 11.4   \n",
       "\n",
       "指标     居民人均食品烟酒支出(元)  居民人均食品烟酒支出比上年增长(%)  居民人均衣着支出(元)  居民人均衣着支出比上年增长(%)  \\\n",
       "2021年         7178.0                 5.1       1419.0              -7.5   \n",
       "2020年         6397.0                 5.1       1238.0              -7.5   \n",
       "2019年         6084.0                 8.0       1338.0               3.8   \n",
       "2018年         5631.0                 4.8       1289.0               4.1   \n",
       "2017年         5374.0                 4.3       1238.0               2.9   \n",
       "2016年         5151.0                 7.0       1203.0               3.3   \n",
       "2015年         4814.0                 7.1       1164.0               5.9   \n",
       "2014年         4494.0                 8.9       1099.0               7.0   \n",
       "2013年         4127.0                 3.6       1027.0               3.6   \n",
       "2012年         3983.0                 9.6        992.0               9.9   \n",
       "\n",
       "指标     居民人均居住支出(元)  居民人均居住支出比上年增长(%)  居民人均生活用品及服务支出(元)  居民人均生活用品及服务支出比上年增长(%)  \\\n",
       "2021年       5641.0               3.2            1423.0                   -1.7   \n",
       "2020年       5215.0               3.2            1260.0                   -1.7   \n",
       "2019年       5055.0               8.8            1281.0                    4.8   \n",
       "2018年       4647.0              13.1            1223.0                    9.1   \n",
       "2017年       4107.0               9.6            1121.0                    7.4   \n",
       "2016年       3746.0               9.6            1044.0                    9.7   \n",
       "2015年       3419.0               6.8             951.0                    6.9   \n",
       "2014年       3201.0               6.7             890.0                   10.3   \n",
       "2013年       2999.0              20.9             806.0                    8.8   \n",
       "2012年       2480.0              12.8             741.0                    9.8   \n",
       "\n",
       "指标     居民人均交通通信支出(元)  居民人均交通通信支出比上年增长(%)  居民人均教育文化娱乐支出(元)  \\\n",
       "2021年         3156.0                -3.5           2599.0   \n",
       "2020年         2762.0                -3.5           2032.0   \n",
       "2019年         2862.0                 7.0           2513.0   \n",
       "2018年         2675.0                 7.1           2226.0   \n",
       "2017年         2499.0                 6.9           2086.0   \n",
       "2016年         2338.0                12.0           1915.0   \n",
       "2015年         2087.0                11.6           1723.0   \n",
       "2014年         1869.0                14.9           1536.0   \n",
       "2013年         1627.0                12.2           1398.0   \n",
       "2012年         1451.0                15.3           1262.0   \n",
       "\n",
       "指标     居民人均教育文化娱乐支出比上年增长(%)  居民人均医疗保健支出(元)  居民人均医疗保健支出比上年增长(%)  \\\n",
       "2021年                 -19.1         2115.0                -3.1   \n",
       "2020年                 -19.1         1843.0                -3.1   \n",
       "2019年                  12.9         1902.0                12.9   \n",
       "2018年                   6.7         1685.0                16.1   \n",
       "2017年                   8.9         1451.0                11.0   \n",
       "2016年                  11.2         1307.0                12.3   \n",
       "2015年                  12.2         1165.0                11.5   \n",
       "2014年                   9.9         1045.0                14.5   \n",
       "2013年                  10.8          912.0                 8.8   \n",
       "2012年                  11.1          838.0                12.7   \n",
       "\n",
       "指标     居民人均其他用品及服务支出(元)  居民人均其他用品及服务支出比上年增长(%)  \n",
       "2021年             569.0                  -11.8  \n",
       "2020年             462.0                  -11.8  \n",
       "2019年             524.0                    9.7  \n",
       "2018年             477.0                    6.8  \n",
       "2017年             447.0                   10.0  \n",
       "2016年             406.0                    4.4  \n",
       "2015年             389.0                    8.7  \n",
       "2014年             358.0                   10.3  \n",
       "2013年             325.0                    5.6  \n",
       "2012年             307.0                   12.9  "
      ]
     },
     "execution_count": 155,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df1 = df1.T\n",
    "df1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 158,
   "id": "c1679202",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "4.6\n",
      "9.7\n"
     ]
    }
   ],
   "source": [
    "df2 = df1.loc['2021年':'2016年']\n",
    "df3 = df1.loc['2016年':'2012年']\n",
    "print(df2['居民人均生活用品及服务支出比上年增长(%)'].mean())\n",
    "print(df3['居民人均生活用品及服务支出比上年增长(%)'].mean())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9a8a1175",
   "metadata": {},
   "outputs": [],
   "source": [
    "#1. 上节课下载的数据，查看数据大小\n",
    "#2. 数据预处理，NaN，查看是否存在NaN,如果不存在，也要写查看的代码，NaN值填充\n",
    "#3. 对数据进行预览的describe\n",
    "#4. 选自己感兴趣的部分进行切片，至少去输出最大、最小、平均、和的其中一项"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
